<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class ShopGoodsSales extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
      Schema::create('shop_goods_sales', function (Blueprint $table) {
          $table->increments('id');
          $table->Integer('goods_id')->unsigned();  // 商品id
          $table->string('goods_name', 100);           // 商品名
          $table->timestamp('start_time');            // 促销开始时间
          $table->timestamp('end_time');              // 促销结束时间
          $table->decimal('price', 10, 2)->unsigned();// 商品原价
          $table->decimal('promate_price', 10, 2)->unsigned(); // 商品促销价
          $table->tinyInteger('status')->unsigned();             // 商品状态
          $table->tinyInteger('promate_num')->unsigned();       // 促销数量
          $table->timestamps();

          $table->foreign('goods_id')
              ->references('id')->on('shop_goods')
              ->onDelete('cascade');
      });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
      Schema::dropIfExists('shop_goods_sales');

    }
}
